//重新排序结果的小函数
const reorder = (list: any, startIndex: any, endIndex: any) => {
    console.log('same-list-lmy', list, startIndex, endIndex)
    const result: { id: string; content: string }[] = Array.from(list);
    const [removed] = result.splice(startIndex, 1);
    result.splice(endIndex, 0, removed);
    console.log('same-result-new==', result)
    return result;
};
export default reorder;


export const reorderQuoteMap = (
    quoteMap: any,
    source: any,
    destination: any,
    overThree = true,
) => {
    console.log('quoteMap', quoteMap, source, destination)
    const current: any[] = [...quoteMap[source.droppableId]];
    const next: any[] = [...quoteMap[destination.droppableId]];
    const target: any = current[source.index];
    console.log('current', current)
    console.log('next', next)
    console.log('target', target)

    // moving to same list
    console.log('moving to same list', source.droppableId === destination.droppableId)
    if (source.droppableId === destination.droppableId) {
        const reordered: any[] = reorder(
            current,
            source.index,
            destination.index,
        );
        const result: any = {
            ...quoteMap,
            [source.droppableId]: reordered,
        };
        console.log('相同列表之后的result==', result)
        return {
            ...result,
        };
    }

    // moving to different list
    // remove from original
    current.splice(source.index, 1);
    // insert into next
    next.splice(destination.index, 0, target);

    const result: any = {
        ...quoteMap,
        [source.droppableId]: current,
        [destination.droppableId]: next,
    };

    console.log('移动之后的新数组666', result)
    return {
        ...result,
    };
};



